package com.itheima.server.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.common.core.controller.BaseController;
import com.itheima.common.core.domain.AjaxResult;
import com.itheima.common.core.page.TableDataInfo;
import com.itheima.server.domain.Transfer;
import com.itheima.server.dto.TransferQueryDto;
import com.itheima.server.service.TransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/transfer")
public class TransferController extends BaseController {

    @Autowired
    private TransferService transferService;

    @GetMapping("/list")
    public TableDataInfo list(TransferQueryDto dto){
        Page<Transfer> page = transferService.pageQuery(dto);
        return super.getDataTable(page.getRecords());
    }

    /**
     * 转派处理
     * @param type 0为线索 1为商机
     * @param outUserId 被转派者id
     * @param getUserId 转派目标id
     * @return
     */

    @PutMapping("/assignment/{type}/{outUserId}/{getUserId}")
    public AjaxResult assignment(
            @PathVariable Integer type,
            @PathVariable Long outUserId,
            @PathVariable Long getUserId
    ){
        HashMap<String, Object> map = new HashMap<>();
        transferService.assignment(type, outUserId, getUserId,map);
        return success(map);
    }




}
